package com.hsh.maoduo.pojo.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hsh.maoduo.constant.common.DateConstants;
import com.hsh.maoduo.util.DataUtil;
import lombok.Data;
import org.apache.logging.log4j.util.Strings;

import java.io.Serializable;
import java.util.Date;

/**
 * @TableName order
 */
@TableName(value = "order")
@Data
public class OrderGoodsVO implements Serializable {
    /**
     * 订单id
     */
    @TableId
    private Integer id;
    /**
     * 订单id
     */
    @TableId
    private String orderNo;

    /**
     * 商品id
     */
    private Integer goodsId;
    /**
     * 商品名称
     */
    private String goodsName;
    /**
     * 商品简称
     */
    private String simpleGoodsName;
    /**
     * 销售id
     */
    private Integer shopId;
    /**
     * 商品简称
     */
    private String shopName;
    /**
     * 商品数量
     */
    private Integer num;

    /**
     *
     */
    private String expressNum;

    /**
     *
     */
    private String note;
    /**
     * 发货时间
     */
    private Date createTime;
    /**
     * 条件筛选  开始时间
     */
    private String startDateTime;
    /**
     * 条件筛选  结束时间
     */
    private String endDateTime;

    private Integer isDelete;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public OutboundVO orderVOToOutBoundVO(Date date) {
        OutboundVO outboundVO = new OutboundVO();
        outboundVO.setNo(DateConstants.PURE_DATETIME_MS_FORMAT.format(date));
        outboundVO.setGoodsId(this.goodsId);
        outboundVO.setGoodsName(this.goodsName);
        outboundVO.setNum(this.num);
        outboundVO.setShopId(this.shopId);
        outboundVO.setNote(DateConstants.NORM_DATETIME_MS_FORMAT.format(date) + "根据订单生成");
        outboundVO.setCreateTime(date);
        return outboundVO;
    }

    public void queryInit() {
        this.orderNo = DataUtil.removeSpaceAndSymbols(this.orderNo);
        this.goodsName = DataUtil.removeSpaceAndSymbols(this.goodsName);
        this.shopName = DataUtil.removeSpaceAndSymbols(this.shopName);
        this.expressNum = DataUtil.removeSpaceAndSymbols(this.expressNum);
    }

    public void init() {
        Date date = new Date();
        if (Strings.isBlank(this.orderNo)) {
            this.orderNo = String.valueOf(date.getTime());
        }
        if (this.createTime == null) {
            this.createTime = date;
        }
    }
}